<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统主页</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
        }
        
        .header {
            background-color: #007bff;
            color: white;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logout-btn {
            background-color: #fff;
            color: #007bff;
            border: none;
            padding: 8px 16px;
            border-radius: 4px;
            cursor: pointer;
        }
        
        .content {
            padding: 20px;
        }
    </style>
</head>
<body>
    <div class="header">
        <h2>邦德系统</h2>
        <button class="logout-btn" onclick="logout()">退出登录</button>
    </div>
    
    <div class="content">
        <h3>欢迎使用邦德系统</h3>
        <p>您已成功登录系统。</p>
        <div id="userInfo"></div>
    </div>

    <script>
        // 页面加载时获取用户信息
        window.onload = function() {
            fetch('/userInfo')
                .then(response => response.json())
                .then(data => {
                    if (data.code === 200) {
                        document.getElementById('userInfo').innerHTML = '<p>当前登录用户ID: ' + data.data + '</p>';
                    } else {
                        alert('用户未登录');
                        window.location.href = '/login.html';
                    }
                });
        };
        
        // 退出登录
        function logout() {
            fetch('/logout', {
                method: 'POST'
            })
            .then(response => response.json())
            .then(data => {
                if (data.code === 200) {
                    window.location.href = '/login.html';
                }
            });
        }
    </script>
</body>
</html>